﻿
@{
    ViewData["Title"] = "参建单位人员统计";
    Layout = "~/Views/Shared/_Layout_Content.cshtml";
}
@section styles
    {
        <link href="~/css/plugins/jqgrid/ui.jqgrid.css" rel="stylesheet" />
         <link href="~/js/plugins/select2/css/select2.css" rel="stylesheet" />
    <environment names="Staging,Production">
        <link rel="stylesheet" href="~/css/grid.min.css" asp-append-version="true" />
    </environment>
}
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>
                <a href="../Statistics/index">参建单位人员统计</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../Statistics/ManagerStatis">参建单位管理人员统计</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../Statistics/GroupWorkerStatis">参建单位施工人员统计</a>
                &nbsp;&nbsp;&nbsp;&nbsp;<a href="../Statistics/WorkerStatis">施工人员统计</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../Statistics/AttendanceStatis">个人考勤统计</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../Statistics/WorkerDateStatis">单位工时统计</a>
            </h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
            </div>
        </div>



        <div class="ibox-content">
            <div class="form-group">
                <div class="row ">
                    <div class="col-md-3">
                        <select id="orginationName" name="orginationName" class="form-control"></select>
                    </div>
                    <div class="col-md-3">
                        <select id="reportType" name="reportType" class="form-control">
                            <option value="0" selected="selected">全部</option>
                            <option value="1">管理人员</option>
                            <option value="2">施工人员</option>
                        </select>
                    </div>
                    <div class="col-md-3">
                        <select name="status" id="status"
                                class="form-control" placeholder="状态">
                            <option value="" selected="selected">全部</option>
                            <option value="1">启用</option>
                            <option value="2">停用</option>
                        </select>
                    </div>
                    <div class="col-md-3">
                        @*<a asp-action="/Xlsx/ExportWorker">导出Excel</a>*@
                        <span class="input-group-btn">
                            <button id="btnSearch" class="btn btn btn-primary" type="button"> <i class="fa fa-search"></i> 搜索</button>
                            <button id="btnExport" class="btn btn btn-primary" type="button"> 导出</button>
                        </span>
                    </div>
                </div>

                <div class="jqGrid_wrapper">
                    <table id="table_list"></table>
                    <div id="pager_list"></div>
                </div>
            
                <div id="jqGrid_Table">

                </div>
            </div>

            </div>

        </div>
    </div>
@section scripts
    {
    <script src="~/js/plugins/jqgrid/jquery.jqGrid.js"></script>
    <script src="~/js/plugins/jqgrid/i18n/grid.locale-cn.js"></script>
    <script src="~/js/jqgrid-list.js"></script>
    <script src="~/js/json2.js"></script>
    <script src="~/js/base.js"></script>
    <script src="~/js/plugins/select2/js/select2.js"></script>
    <script src="~/js/BindSelect.js"></script>
    <environment names="Staging,Production">
        <script src="~/js/grid.min.js" asp-append-version="true"></script>
      
    </environment>


       

    <script>

        $("#btnExport").click(function () {
            window.open('@Url.Action("ExportWorker","Xlsx")');
           
        });



        function GetSouce() {
              $.ajax({
                url: '@Url.Action("GetStatistics")',
                type: "GET",
                dataType: "json",
                async: true,
                data: {
                    orginationName: $("#orginationName").find("option:selected").text(),
                    reportType: $("#reportType").val(),
                    status: $("#status").val(),
                },
                success: function (data) {
                    var table = ('<table class="ui-jqgrid-htable ui-common-table table table-bordered">');
                    table += '<tr class="ui-jqgrid-labels" role="row">';
                    table += '<td role="columnheader" class="ui-th-column ui-th-ltr"> 公司名称</td>';
                    //for (var i = 0; i < data.rows.length; i++) {
                        $.each(data.rows[0].employers, function (key, value) {
                            table += '<td role="columnheader" class="ui-th-column ui-th-ltr"> ' + key + '</td>';
                        });
                    //}
                    table += '<td role="columnheader" class="ui-th-column ui-th-ltr"> 状态</td>';
                    table += '</tr>';
                    for (var i = 0; i < data.rows.length; i++) {
                        table += '<tr class="ui-jqgrid-labels" role="row">';
                        table += '<td role="columnheader" class="ui-th-column ui-th-ltr"> ' + data.rows[i].organizationName +'</td>';
                        $.each(data.rows[i].employers, function (key, value) {
                            table += '<td role="columnheader" class="ui-th-column ui-th-ltr"> ' + value + '</td>';
                        });
                        table += '<td role="columnheader" class="ui-th-column ui-th-ltr"> ' + data.rows[i].state + '</td>';
                        table +='</tr>';
                    }
                    table += '</table>';
                    //alert(table)
                    $("#jqGrid_Table").append(table);
                }
            });
        }

        $(document).ready(function () {
            BindSelect("orginationName", "/Company/GetCompanys");
            GetSouce();
            $("#btnSearch").click(function () {
                $("#jqGrid_Table").html("");
                GetSouce();
            });
        });


        //BindSelect("JobId", "/JobPositionType/GetJobPositionTypes");

        function searchData() { //搜索
            GetSouce();
            //var json = {
            //    company: $("#company").val(),
            //    job: $("#job").val(),
            //    state: $("#job").val(),
            //};
            //XPage.Search(json);
        }


        @*$(document).ready(function() {
            var config = {
                title: '公司列表',
                url: '@Url.Action("GetListWithPager")',
                colNames: ['参建单位', '管理人员', '施工人员', '技术人员', '其他', '状态'],
                colModel: [
                    { name: 'id', index: 'id', width: 60, key: true, hidden: true },
                    { name: 'organizationName', index: 'organizationName', width: 60 },
                    { name: 'organizationName', index: 'organizationName', width: 60 },
                    { name: 'address', index: 'address', width: 60 },
                    { name: 'contact', index: 'contact', width: 60 },
                    { name: 'stats', index: 'stats', width: 60 },
                ]
            };
            JucheapGrid.Load(config);
            $("#btnSearch").bind("click", searchData);

        });*@
    </script>
}